home *** CD-ROM | disk | FTP | other *** search
- /*
- * illustrates use of directory routines
- *
- * If _ABI_SOURCE defined, include <dirent.h> instead of <sys/dir.h>
- * and redefine the name of the directory struct
- */
-
- #include <stdio.h>
- #include <sys/types.h>
- #ifdef _ABI_SOURCE
- #define dirent direct
- #include <dirent.h>
- #else /* _ABI_SOURCE */
- #include <sys/dir.h>
- #endif /* _ABI_SOURCE */
-
- main ()
- {
- DIR *dp;
- struct direct *dep;
-
- if ((dp = opendir (".")) == NULL)
- {
- fprintf (stderr, "cannot open current directory for reading\n");
- exit (1);
- }
-
- while ((dep = readdir (dp)) != NULL)
- (void) printf ("%s\n", dep->d_name);
- closedir (dp);
- return (0);
- }
-